package org.devops

class Constants implements Serializable{
    public static final String VALUES_URL = "http://172.30.11.14:8002/api/v4/projects/198/repository/files/"
    public static final String HARBOR_PROJECT = "192.168.8.206/library"
    public static final String JENKINS_DOCKERFILES_DIR = "_dockerfiles"
    public static final String DEPLOY_CONF_DIR = "_deploy-conf"
    public static final String GIT_CREDENTIAL_ID = "devops"
    public static final String VERSION = "stable"
    public static final String PROD_BRANCH_FILTER = ".*"
    public static final String DEFAULT_BRANCH_FILTER = ".*"
    //上传到ansible服务器上的压缩文件名称
    public static final String ANSIBLE_STORE_FILE = "deploy.tar"
    public static final String DEFAULT_JAVA_RUN_IMAGE = "192.168.8.206/library/adoptopenjdk:8-jdk-hotspot"
    public static final String DEFAULT_NGINX_RUN_IMAGE = "192.168.8.206/docker/nginx:1.22.0"
    public static final Set<String> SPECIAL_SERVICE = new HashSet<String>(){
        {
            add("iot-prod")
        }
    }
    public static final PROJECT_BASE_URL = "http://192.168.8.151:8080"
    public static final ROLLBACK_SCRIPT = """import groovy.json.JsonSlurper
def jobName = getProperty("JOB_NAME")
def conn = new URL("${PROJECT_BASE_URL}/projectInfo/last5?job_name=\${jobName}").openConnection()
conn.setDoOutput(true)
conn.connect()
def json = new JsonSlurper().parseText(conn.inputStream.getText('UTF-8'))

def selectValues = []
for (r in json.data){
     selectValues += ["\${r.build_number} | \${r.time} | \${r.app} | \${r.branch} | \${r.commit} | \${r.msg}"]
}

return selectValues"""
}
